﻿using AutoMapper;
using MediatR;
using SheepStorage.API.Application.Command.SheepMarkCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.Entity;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.SheepMarkHandler
{
    public class SheepMrkEditCommandHandler : IRequestHandler<SheepMarkEditCommand, Results<SheepMark>>
    {
        private readonly ISheepMarkService _sheepMarkService;
        private readonly IMapper _mapper;
        public SheepMrkEditCommandHandler(ISheepMarkService sheepMarkService, IMapper mapper)
        {
            _sheepMarkService = sheepMarkService;
            _mapper = mapper;
        }
        /// <summary>
        /// 戴标反填
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Results<SheepMark>> Handle(SheepMarkEditCommand request, CancellationToken cancellationToken)
        {
            return Results<SheepMark>.DataResult(await _sheepMarkService.GetSheepMark(request.SheepMarkId));
        }
    }
} 
